package com.yupi.springbootinit.controller;/*
@author name
@data 2025/3/25-10:46
*/

import com.yupi.springbootinit.common.BaseResponse;
import com.yupi.springbootinit.common.ResultUtils;
import com.yupi.springbootinit.service.ChatMessageService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * AI对话接口
 */

@RestController
@RequestMapping("/chatMsg")
public class chatMessageController {

    @Resource
    private ChatMessageService chatMessageService;

    @PostMapping("/send/{roomId}")
    public BaseResponse<String> doChat(HttpServletRequest request, @PathVariable String roomId, String userPrompt){
        String AIResponse = chatMessageService.doChatOfDB(request, roomId, userPrompt);
        return ResultUtils.success(AIResponse);
    }
}
